﻿@{
    ViewBag.Title = "Custome";
}

@section scripts
{   
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>   
}
<form id="form1" runat="server" method="post" style = "width:100%;height:100%">
    <div id="layout1" class="mini-layout" style="width:100%;height:100%;"  borderStyle="border:2px;">
        <div title="north" region="north" height="40"showHeader = "false" >
            <div class="mini-toolbar" style="padding:2px;border-top:0;border-left:0;border-right:0;">              
                <table style="width:100%;">
                    <tr>
                        <td style="width:100%;">                            
                            <a class="mini-button" id="freshuser" name="freshuser" iconCls="icon-search" onclick="LoadListData()" plain="true">刷新</a>
                            <a class="mini-button" name="save" iconCls="icon-save" onclick="saveData" plain="true"  ennable="true">保存</a>
                            <span class="separator"></span>
                            <a class="mini-button" iconCls="icon-close" onclick="CloseWindow" plain="true">关闭</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div title="south" region="south" showSplit="false" showHeader="false" height="40px" showSplitIcon="false" >
            提示：选择多个用户可批量保存（注：保存的权限相同）
        </div>
        <div title="用户资料" region="west" width="450px"showSplitIcon="true"  showHeader = "true">
            <table>
                <tr>
                    <td width ="50px" align="right">查找: </td>
                    <td width ="150px" ><input class="mini-textbox" width ="150px" id ="FUserKey" name = "FUserKey"/>
                    </td>
                </tr>
            </table>
            <div class="mini-fit" >
                <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" pageSize="15"
                        borderStyle="border:1;" url="GetUserList"
                        allowCellSelect="true" allowCellEdit="true" showColumnsMenu="true" fitColumns="false"  
                        sortMode="client" onselectionchanged="onSelectionChanged" multiSelect="true">
                    <div property="columns">
                        <div type="checkcolumn" >选行</div>
                        <div field="FNumber" name="FNumber" width="100" headeralign="center" allowsort="true">用户编码</div>
                        <div field="FName" name="FName" width="100" headeralign="center" allowsort="true">用户名称</div>
                        <div field="userType" name="userType" width="80" headeralign="center" allowsort="true">用户类型</div>
                        <div field="FCorpName" name="FCorpName" width="120" headeralign="center" allowsort="true">商户名称</div>
                    </div>
                </div>
             </div>
        </div>
        <div region="center" showHeader = "false" >
            <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;height:100%;" plain="false"  borderStyle="border:0;">
                <div name="tabPOS" title="前台权限" >
                  <table width = "300px" height ="100%" style="margin-left:20px;">
                        <tr>
                            <td width="250px" height="100%" valign="top">
                                <div id="mChanegelsj" class="mini-checkbox" name="mChanegelsj" readonly="false" text="更改数量"></div><br />
                                <div id="mClearMoney" class="mini-checkbox" name="mClearMoney" readonly="false" text="交班处理"></div><br />
                                <div id="mReturnPrs" class="mini-checkbox" name="mReturnPrs" readonly="false" text="退货处理"></div><br />
                                <div id="mOpenMoneyBox" class="mini-checkbox" name="mOpenMoneyBox" readonly="false" text="弹钱箱"></div> <br />
                                <div id="mOnePr_Agio" class="mini-checkbox" name="mOnePr_Agio" readonly="false" text="单个商品折扣"></div> <br />
                                <div id="mCancelOrder" class="mini-checkbox" name="mCancelOrder" readonly="false" text="整单取消"></div> <br />
                                <div id="mPrinBjMore" class="mini-checkbox" name="mPrinBjMore" readonly="false" text="补票打印"></div><br />
                                <div id="mSystemSetup" class="mini-checkbox" name="mSystemSetup" readonly="false" text="系统设置"></div><br />
                                <div id="mDeleteARow" class="mini-checkbox" name="mDeleteARow" readonly="false" text="单行删除"></div><br />
                                <div id="mHanguppOrder" class="mini-checkbox" name="mHanguppOrder" readonly="false" text="挂单"></div><br />
                                <div id="mPreferential" class="mini-checkbox" name="mPreferential" readonly="false" text="优惠金额"></div> <br />
                                <div id="mOrderAgio" class="mini-checkbox" name="mOrderAgio" readonly="false" text="全单折扣"></div> <br />
                                <div id="mPr_Largess" class="mini-checkbox" name="mPr_Largess" readonly="false" text="商品增送"></div><br />
                                <div id="mChangeDjBz" class="mini-checkbox" name="mChangeDjBz" readonly="false" text="更改单价"></div> <br />
                                <div id="mPrinDataBz" class="mini-checkbox" name="mPrinDataBz" readonly="false" text="收款员清单"></div><br />
                                <div id="mUserKey_Bz" class="mini-checkbox" name="mUserKey_Bz" readonly="false" text="自定义键盘"></div><br />
                                <div id="mPosOrderBz" class="mini-checkbox" name="mPosOrderBz" readonly="false" text="大宗购物单销售"></div><br />
                                <div id="mField_01" class="mini-checkbox" name="mField_01" readonly="false" text="前台交款单"></div><br />
                                <div id="mField_02" class="mini-checkbox" name="mField_02" readonly="false" text="前台库存盘点"></div><br />
                                <div id="mField_03" class="mini-checkbox" name="mField_03" readonly="false" text="前台查询交易记录"></div><br />
                                <div id="mField_04" class="mini-checkbox" name="mField_04" readonly="false" text="前台会员充值、积分"></div><br />
                                <div id="mField_05" class="mini-checkbox" name="mField_05" readonly="false" text="前台会员卡发卡"></div><br />
                                <div id="mField_06" class="mini-checkbox" name="mField_06" readonly="false" text="补印交班单"></div><br />
                                <div id="mField_07" class="mini-checkbox" name="mField_07" readonly="false" text="查看成本价"></div><br />
                                <div id="mField_08" class="mini-checkbox" name="mField_08" readonly="false" text="前台零售日结"></div><br />
                                <div id="mPurAmount" class="mini-checkbox" name="mPurAmount" readonly="false" text="进价金额显示"></div><br />
                                <div id="mDepositRet" class="mini-checkbox" name="mDepositRet" readonly="false" text="会员充值退款"></div><br />
                                <div id="mFSeeStc" class="mini-checkbox" name="mFSeeStc" readonly="false" text="盘点时明盘"></div><br />
                                <div id="mDepositeTime" class="mini-checkbox" name="mDepositeTime" readonly="false" text="次卡消费"></div><br />
                                &nbsp;
                            </td>
                            <td width = "150px" height ="100%"  align="left" valign="top">
                                <table style="width:100%;">
                                    <tr>
                                        <td width="80px" height ="30px" align="right">最大折扣： </td>
                                        <td style="width:100%;">
                                            <input name="mMaxPr_Agio" class="mini-spinner" minValue="0" maxValue="1" changeOnMousewheel ="false" showbutton="false" 
                                                increment ="0"showbutton="false" style="width:150px;" />(提示：请输小数点数字，0.9表示9折,0表示不限制。）                
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="80px" height ="30px" align="right">最大优惠金额： </td>
                                        <td style="width:100%;">
                                            <input name="mMaxOrderJe" class="mini-spinner" minValue="0" maxValue="999999" 
                                                changeOnMousewheel ="false" showbutton="false" increment ="0"showbutton="false" style="width:150px;" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="80px" height ="30px" align="right"> </td>
                                        <td style="width:100%;">
                                            <input id="FUserID" name="FUserID" class="mini-hidden"/>
                                        </td>
                                    </tr>
                                </table> 
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
<script>
    mini.parse();
    var grid = mini.get("datagrid1");
    function FormShown() {
        LoadListData();
    }

    //加载用户列表
    function LoadListData() {
        var sSystemAppID = parent.window.getSystemAppID();
        var mKeys = mini.get("FUserKey").getValue()
        var json = "[{";
        json = json + "'FSystemAppID':" + "'" + sSystemAppID + "',";
        json = json + "'search':'" + mKeys + "'";
        json = json + "}]";
        grid.load({ json: json });
    }

    function onSelectionChanged() {        
        var row = grid.getSelected();
        if (row) {
            mini.getbyName("FUserID").setValue(row.FItemID);
            var param = "[{'FUserID':'" + row.FItemID + "','mSystemAppID':'" + parent.window.getSystemAppID() + "'}]";
            $.post("GetPowerInfo", { json: param }, function (data) {
                var mdata = mini.decode(data);
                if (mdata.data.length > 0) {
                    setData(mdata.data[0]);
                }
            });
        } else {
            mini.alert("请选中一个用户");
        }
    }

    function setData(data) {
        mini.get("mChanegelsj").setChecked(data.mChanegelsj);
        mini.get("mClearMoney").setChecked(data.mClearMoney);
        mini.get("mReturnPrs").setChecked(data.mReturnPrs);
        mini.get("mOpenMoneyBox").setChecked(data.mOpenMoneyBox);
        mini.get("mOnePr_Agio").setChecked(data.mOnePr_Agio);
        mini.get("mCancelOrder").setChecked(data.mCancelOrder);
        mini.get("mPrinBjMore").setChecked(data.mPrinBjMore);
        mini.get("mSystemSetup").setChecked(data.mSystemSetup);
        mini.get("mDeleteARow").setChecked(data.mDeleteARow);
        mini.get("mHanguppOrder").setChecked(data.mHanguppOrder);
        mini.get("mPreferential").setChecked(data.mPreferential);
        mini.get("mOrderAgio").setChecked(data.mOrderAgio);
        mini.get("mPr_Largess").setChecked(data.mPr_Largess);
        mini.get("mChangeDjBz").setChecked(data.mChangeDjBz);
        mini.get("mPrinDataBz").setChecked(data.mPrinDataBz);
        mini.get("mUserKey_Bz").setChecked(data.mUserKey_Bz);
        mini.get("mPosOrderBz").setChecked(data.mPosOrderBz);
        mini.get("mField_01").setChecked(data.mField_01);
        mini.get("mField_02").setChecked(data.mField_02);
        mini.get("mField_03").setChecked(data.mField_03);
        mini.get("mField_04").setChecked(data.mField_04);
        mini.get("mField_05").setChecked(data.mField_05);
        mini.get("mField_06").setChecked(data.mField_06);
        mini.get("mField_07").setChecked(data.mField_07);
        mini.get("mField_08").setChecked(data.mField_08);
        mini.get("mPurAmount").setChecked(data.mPurAmount); 
        mini.get("mDepositRet").setChecked(data.mDepositRet);
        mini.get("mFSeeStc").setChecked(data.mFSeeStc);
        mini.getbyName("mMaxPr_Agio").setValue(data.mMaxPr_Agio);
        mini.getbyName("mMaxOrderJe").setValue(data.mMaxOrderJe);
        mini.getbyName("mDepositeTime").setValue(data.mDepositeTime);
    }  

    function saveData() {
        var rows = grid.getSelecteds();
        if (rows) {
            var form = new mini.Form("#form1");
            form.validate();
            if (form.isValid() == false) return;
            var data = form.getData(true, false);
            data.users = rows;
            var datajson = mini.encode(data);            
            var param = parent.window.getSystemAppID();
            $.post("SavePowerInfo", { mjson: datajson, mSystemAppID: param }, function (data) {
                var ret = mini.decode(data);
                if (ret.status == "1")
                    mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
                else
                    mini.showTips({ content: ret.error, state: "danger", x: "center", y: "top", timeout: 3000 });
            });
        } else {
            mini.alert("请选中一个用户");
        }
    }
</script>
</form>